<template>
  <el-menu
    default-active="2"
    class="el-menu-vertical-demo"
    @open="handleOpen"
    @close="handleClose"
    :collapse="!$store.state.homeModule.navBool"
    router
  >
  <template v-for="(v) in router.options.routes[1].children" :key="v.path">
    <el-sub-menu :index="v.path" v-if="v.children">
      <template #title>
        <el-icon><component :is="v.meta.icon"></component></el-icon>
        <span>{{ v.meta.title}}</span>
      </template>
      <el-menu-item-group v-for="(val) in v.children" :key="val.path">
        <el-menu-item :index="val.path">{{ val.meta.title}}</el-menu-item>
      </el-menu-item-group>
    </el-sub-menu>
    
    <el-menu-item :index="v.path" v-else>
        <el-icon><component :is="v.meta.icon"></component></el-icon>
        <span>{{ v.meta.title }}</span>
    </el-menu-item>
  </template>

  </el-menu>
</template>

<script lang="ts" setup>
import { onMounted } from "vue"
// import {
//   // Document,
//   // Menu as IconMenu,
//   // Location,
//   Setting,
// } from '@element-plus/icons-vue'

import { useRouter } from "vue-router"
let router=useRouter()
const handleOpen = (key: string, keyPath: string[]) => {
  console.log(key, keyPath)
}
const handleClose = (key: string, keyPath: string[]) => {
  console.log(key, keyPath)
}  

onMounted(()=>{
  console.log(router.options.routes)
})
</script>

<style scoped>
    
</style>
